/*
 * File Name     : @(#)IDTO.java
 * Creation Date : Mar 2, 2009
 * Author        : anirudh
 * 
 * Copyright 2009 Anirudh Vyas
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hcis.dto;

import hcis.core.engine.event.IEvent;
import hcis.dto.cache.ICache;
import hcis.model.IModel;
import hcis.model.annotation.HCISEntity;

import java.io.Serializable;

/**
 * A DTO uses a broadcasting agent to allow events to be queued and be processed by the HCIS engine and allow business operations to happen as requested.
 * 
 * @author avyas
 * @param <MODEL>
 *            model type.
 * @param <MODELID>
 *            model id type.
 */
@HCISEntity
public interface IDTO<MODEL extends IModel<MODELID>, MODELID extends Serializable> extends Serializable {

	/**
	 * Gets the bound model.
	 * 
	 * @return bound model to get.
	 */
	public abstract MODEL getBoundModel();

	/**
	 * Sets the bound model.
	 * 
	 * @param pModel
	 *            model to set.
	 */
	public abstract void setBoundModel(final MODEL pModel);

	/**
	 * Gets the bound cache. A cache must be initialized at the time of construction of a DTO, once initialized contents of cache must be maintained consistently within a DTO. It is for this reason it
	 * is recommended to use {@link ICache#flush()} and other methods very carefully; inconsistent data can often lead to other complications.
	 * 
	 * @return cached data to get.
	 */
	public abstract ICache<? extends IEvent<? extends IDTO<MODEL, MODELID>, MODEL, MODELID>, ? extends IDTO<MODEL, MODELID>, MODEL, MODELID> getCache();
}
